package cn.gson.work.model.pojos;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
public class Budget {
    private long bId;
    private Long userNo;
    private String bName;
    private Integer bMoney;
    private Timestamp bTime;
    private Budcate budcate;
    private Project project;
    private User user;


    @Id
    @Column(name = "B_ID")
    public long getbId() {
        return bId;
    }

    public void setbId(long bId) {
        this.bId = bId;
    }

    @Basic
    @Column(name = "USER_NO")
    public Long getUserNo() {
        return userNo;
    }

    public void setUserNo(Long userNo) {
        this.userNo = userNo;
    }

    @Basic
    @Column(name = "B_NAME")
    public String getbName() {
        return bName;
    }

    public void setbName(String bName) {
        this.bName = bName;
    }

    @Basic
    @Column(name = "B_MONEY")
    public Integer getbMoney() {
        return bMoney;
    }

    public void setbMoney(Integer bMoney) {
        this.bMoney = bMoney;
    }

    @Basic
    @Column(name = "B_TIME")
    public Timestamp getbTime() {
        return bTime;
    }

    public void setbTime(Timestamp bTime) {
        this.bTime = bTime;
    }

    @ManyToOne
    @JoinColumn(name = "BC_ID", referencedColumnName = "BC_ID")
    public Budcate getBudcate() {
        return budcate;
    }

    public void setBudcate(Budcate budcate) {
        this.budcate = budcate;
    }
    @ManyToOne
    @JoinColumn(name = "P_ID", referencedColumnName = "P_ID")
    public Project getProject() {
        return project;
    }

    public void setProject(Project project) {
        this.project = project;
    }

    @ManyToOne
    @JoinColumn(name = "USER_NO", insertable=false ,updatable=false)
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Budget budget = (Budget) o;
        return bId == budget.bId &&
                Objects.equals(userNo, budget.userNo) &&
                Objects.equals(bName, budget.bName) &&
                Objects.equals(bMoney, budget.bMoney) &&
                Objects.equals(bTime, budget.bTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(bId, userNo, bName, bMoney, bTime);
    }
}
